package Test11_03;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class ConnectionDemo03 {
	public static final String DBDRIVER = "com.mysql.jdbc.Driver";
	public static final String DBURL = "jdbc:mysql://localhost:3306/publicdemoprac";
//	public static final String DBURL = "jdbc:mysql://localhost:3306/publicdemoprac?useUnicode=true&amp;characterEncoding=UTF-8";
	public static final String DBUSER = "root";
//	public static final String DBPASS = "root";
	public static final String DBPASS = "123456";
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Connection conn = null;
		Statement stat = null;
		String createTable = "create table userprac(id int auto_increment primary key,"+"name varchar(30) not null,password varchar(32)not null,age int(3)) ";
		String insertValue = "insert into userprac(name,password,age)value('小明','666666',28);";
		try{
			Class.forName(DBDRIVER);
			conn=DriverManager.getConnection(DBURL, DBUSER, DBPASS);
			stat = conn.createStatement();
			stat.executeUpdate(createTable);
			stat.executeUpdate(insertValue);
			stat.close();
			conn.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
